var app =new Vue({
    el:"#xp-wrapper",
    data:{
        odlManID: "",
        time:'',
        runnings:""
    },
    mounted:function (){
        this.odlManID=getQueryString("id");
        this.RunningWater(this.odlManID,this.time);
    },
    methods:{
        RunningWater(odlManID,time){
            let data=new URLSearchParams();
            data.append("odlManID",odlManID);
            data.append("consumptionTime",time);
            axios({
                method: 'post',
                url: "/yly-api/user/queryRunningWater",
                data:data,
                headers:{"token":localStorage.token}
            }).then((ins) => {
                let nhDto = ins.data;
                let runnings = nhDto.data;
                if (nhDto.code == 200) {
                    console.log(runnings);
                    app.runnings = runnings;
                } else if (nhDto.code == 500) {
                    location.href = "/500.html";
                }
            }).catch(error=>{
                console.log(error.response.status);
                if (error.response.status==401){
                    alert("请先登录!");
                    location.href="index.html";
                }else if (error.response.status==403){
                    alert("用户已过期，请重新登录！");
                    localStorage.token=null;
                    location.href="index.html";
                }
            });
        }
    }
});
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg); //r是一个数组
    if (r != null) return unescape(r[2]); return null;
}